package com.hksj.em.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.common.core.model.Rest;
import com.hksj.em.enums.PageEnum;
import com.hksj.em.query.CallCaregiverQuery;
import com.hksj.em.query.SurgicalQuery;
import com.hksj.em.service.SurgicalService;
import com.hksj.em.vo.SurgicalVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * @author zengke
 * @version 1.0
 * @see SurgicalController
 * @since 2025/03/25 10:29
 */

@Api(tags = "数据同步-排台管理")
@RequestMapping(value = "/api/surgical")
@RestController
public class SurgicalController {

    @Resource
    private SurgicalService surgicalService;


    @ApiOperation(value = "动态查询排台信息",response = SurgicalVO.class)
    @PostMapping("/querySurgicalList")
    public Rest querySurgicalList(@RequestBody SurgicalQuery query){

        //判断是否分页查询
        if (Objects.equals(query.getPageStatus(), PageEnum.PAGE.getType())){

            //进行分页查询
            IPage<SurgicalVO> page = surgicalService.querySurgicalListByPaging(query);

            //返回分页结果
            return Rest.ok(page);
        } else {

            //不进行分页查询
            List<SurgicalVO> surgicalList = surgicalService.querySurgicalList(query);

            //返回动态查询结果
            return Rest.ok(surgicalList);
        }
    }


    @ApiOperation(value = "同步手术排台信息")
    @GetMapping(value = "/syncSurgical")
    public Rest<String> syncSurgical(){
        String result = surgicalService.syncSurgical();
        return Rest.ok(result);
    }

    @ApiOperation(value = "分页查询家属等候区手术状态信息",response = SurgicalVO.class)
    @PostMapping("/querySurgeryStatusForFamilyWaitingArea")
    public Rest querySurgeryStatusForFamilyWaitingArea(@RequestBody CallCaregiverQuery callCaregiverQuery){
        IPage<SurgicalVO> page = surgicalService.querySurgeryStatusForFamilyWaitingArea(callCaregiverQuery);
        return Rest.ok(page);
    }
}
